<template>
    <a-input-number v-model="internalValue" class="w-full bacClass" @change="inputChange" :min="0" :max="dynamicMaxValue"/>
</template>

<script setup lang="ts">
import { ref, watch } from 'vue';

const props = withDefaults(
  defineProps<{
    params: any
  }>(),
  {
    params: {},
  }
);

const internalValue = ref<any>(props.params.value);
const dynamicMaxValue = ref<number>(999999999999); // 初始化动态最大值为100

onMounted(() => {
  // 在这里根据需要设置 dynamicMaxValue 的初始值
  if(props.params.maxNumberKey && props.params.data[props.params.maxNumberKey]||props.params.data[props.params.maxNumberKey]==0){
    dynamicMaxValue.value = props.params.data[props.params.maxNumberKey]
  }
});

const inputChange = (val:any) => {
  if (Number(val) > Number(dynamicMaxValue.value)) {
    val = dynamicMaxValue.value
    }
  props.params.setValue(val)
}
</script>

<style scoped>
.w-full {
  width: 100%;
}
</style>
